import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, ObjectId } from 'mongoose';
import * as mongoose from 'mongoose';
import { User } from '@api/user/schemas/user.schema';
import { Photos } from './photos.schema';

export type PhotosProfileDocument = PhotosProfile & Document;
@Schema()
export class PhotosProfile {
    _id: ObjectId;
    /**
     * 作品id
     */
    @Prop({ type: mongoose.Schema.Types.ObjectId, ref: 'Photos', index: true, unique: true })
    photos: Photos | ObjectId;

    /**
     * 作者用户
     */
    @Prop({ type: mongoose.Schema.Types.ObjectId, ref: 'User', index: true })
    user: User | ObjectId;
    /**
     * 总销售额（预留字段）
     */
    @Prop({
        required: true,
        default: 0,
    })
    totalSales: number;
    /**
     * 总点击
     */
    @Prop({
        required: true,
        default: 0,
    })
    totalVisit: number;
    /**
     * 日点击
     */
    @Prop({
        required: true,
        default: 0,
    })
    dayVisit: number;
    /**
     * 周点击
     */
    @Prop({
        required: true,
        default: 0,
    })
    weekVisit: number;
    /**
     * 月点击
     */
    @Prop({
        required: true,
        default: 0,
    })
    monthVisit: number;
    /**
     * 最后一次被访问时间
     */
    @Prop({
        required: true,
    })
    lastVisit: Date;
    /**
     * 总下载
     */
    @Prop({
        required: true,
        default: 0,
    })
    totalDown: number;
    /**
     * 日下载
     */
    @Prop({
        required: true,
        default: 0,
    })
    dayDown: number;
    /**
     * 周下载
     */
    @Prop({
        required: true,
        default: 0,
    })
    weekDown: number;
    /**
     * 月下载
     */
    @Prop({
        required: true,
        default: 0,
    })
    monthDown: number;
}

export const PhotosProfileSchema = SchemaFactory.createForClass(PhotosProfile);
